<template>
  <div>
    <el-tabs v-model="activeName" style="padding: 10px 15px 0 0" type="card" @tab-click="handleTabClick">
      <template v-for="item in optList">
        <el-tab-pane :key="item.code" :name="item.code" :label="item.name" />
      </template>
    </el-tabs>
    <router-view />
  </div>
</template>
<script>
import { mapState } from 'vuex';
export default {
  data() {
    return {
      activeName: '',
      optList: [
        {
          code: 'LogisticsHotel',
          name: '酒店设置'
        },
        {
          code: 'LogisticsPickUp',
          name: '接待设置'
        },
        {
          code: 'LogisticsCatering',
          name: '就餐设置'
        }
      ]
    };
  },
  computed: {
    ...mapState({
      tenantId: state => state.user.tenantId
    })
  },
  created() {
    this.activeName = this.$route.query.logisticType || 'LogisticsHotel';
  },
  methods: {
    handleTabClick(tabItem) {
      const { query } = this.$route;
      query.logisticType = tabItem.name;
      this.$router.push({
        name: tabItem.name,
        query: query
      });
    }
  }
};
</script>
